-
Notifications
You must be signed in to change notification settings - Fork 369
Enforce no real filesystem writes during unit tests #700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…geProvider::new_overlay()
diskann-disk/src/utils/aligned_file_reader/storage_provider_aligned_file_reader.rs
Show resolved
Hide resolved
diskann-disk/src/utils/aligned_file_reader/storage_provider_aligned_file_reader.rs
Outdated
Show resolved
Hide resolved
diskann-disk/src/utils/aligned_file_reader/storage_provider_aligned_file_reader.rs
Show resolved
Hide resolved
* Initial plan * Address PR feedback: revert comments and refactor test helper functions Co-authored-by: arrayka <1551741+arrayka@users.noreply.github.com> * Revert test_index_path() to return String and remove .to_string_lossy() Co-authored-by: arrayka <1551741+arrayka@users.noreply.github.com> * Remove test_index_os_path() and use test_index_path() instead Co-authored-by: arrayka <1551741+arrayka@users.noreply.github.com> * Revert commit 90934ad Co-authored-by: arrayka <1551741+arrayka@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: arrayka <1551741+arrayka@users.noreply.github.com>
| pub fn benchmark_copy_aligned_data(c: &mut Criterion) { | ||
| let tmp_dir = TempDir::with_prefix(BENCHMARK_ID).expect("Failed to create temporary directory"); | ||
| // Use physical file system rather than memory for testing the actual disk read/write | ||
| #[allow(clippy::disallowed_methods)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use
#[expect(clippy::disallowed_methods, "reason")]to do two things:
expectwill complain if disallowed method is not actually used (helping with maintanence)- The following reason helps document why an exception is made.
| pub fn benchmark_copy_aligned_data_iai() { | ||
| let tmp_dir = TempDir::with_prefix(BENCHMARK_ID).expect("Failed to create temporary directory"); | ||
| // Use physical file system rather than memory for testing the actual disk read/write | ||
| #[allow(clippy::disallowed_methods)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment here with expect instead of allow.
| let storage_provider = VirtualStorageProvider::new(vfs); | ||
| let pq_pivots_path: &str = "test_data/sift/siftsmall_learn_pq_pivots.bin"; | ||
| let storage_provider = VirtualStorageProvider::new_overlay(workspace_root); | ||
| let pq_pivots_path: &str = "/test_data/sift/siftsmall_learn_pq_pivots.bin"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something we should also do (maybe in another PR) is to replace all uses of test_data with the file system resolution in diskann-utils. I think a few fell through the cracks when test data was consolidated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes sense. I've created an issue to track this: #704
| impl VirtualStorageProvider<OverlayFS> { | ||
| /// Create a two-layer overlay filesystem with an in-memory filesystem for writes | ||
| /// on top of the physical filesystem for reads. | ||
| pub fn new_overlay<P: AsRef<std::path::Path>>(path: P) -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you see any value in making VirtualStorageProvider::new much harder to call to encourage use of new_overlay or new_memory? Maybe with like a new_physical and then linting that with clippy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
I've created an issue to track this: #703
Why
What
vfs::PhysicalFS::newto the list of disallowed methods inclippy.toml